/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2024-01-02 11:41:35
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-01-03 15:31:10
 * @FilePath: /yt-devops/lib/components/authority_widget.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import 'package:flutter/material.dart';
import 'package:yt_devops/utils/func_utils.dart';

class AuthorityWidget extends StatelessWidget {
  final List<String>? authority;
  final Widget? child;
  const AuthorityWidget({super.key, required this.authority, this.child});

  bool validateAuth() {
    var map = FuncUtils.authentication(authorityList: authority);
    return map['pass'];
  }

  @override
  Widget build(BuildContext context) {
    return Offstage(
      offstage: !validateAuth(),
      child: child,
    );
  }
}
